const parser = require('@babel/parser');
const traverse = require('@babel/traverse').default;
const generator = require('@babel/generator').default;
const t = require('@babel/types');

function transformCode(code) {
  const ast = parser.parse(code);

  traverse(ast, {
    VariableDeclaration(path) {
      if (path.node.kind !== 'const') {
        // Replace the kind of the variable declaration with 'const'
        path.node.kind = 'const';
      }
    }
  });
  
  const output = generator(ast, {}, code);
  return output.code;
}

// 测试插件
const originalCode = `let a = 1; var b = 2;`;
console.log(transformCode(originalCode));